/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.curso.service;

import com.curso.dao.serializables.UserDaoSer;
import com.curso.exception.MyException;
import com.curso.model.Address;
import com.curso.model.Role;
import com.curso.model.User;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author hp
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        UserService userService= new UserService();
        

        List<User> list = userService.getAll();


        for(User user : list){
            System.out.println(user);
        }
      /*
       //Create a user
        User u = new User();
        u.setFirstName("Homero");
        u.setLastName("Simpsons");
        u.setUsername("homer.simpsons");
        u.setPassword("operator");
        u.setPasswordHint("role?");
        u.setEmail("homer.simpsons@gmail.com");
        u.setPhoneNumber("555-555-5555");
        u.setWebsite("N/A");
        u.setEnabled(true);
        u.setAccountExpired(false);
        u.setAccountLocked(false);
        u.setCredentialsExpired(false);

        Role r = new Role();
        r.setName("admin");
        r.setDescription("All privileges");

        u.addRole(r);

        r = new Role();
        r.setName("operator");
        r.setDescription("Some privileges");

        u.addRole(r);

        Address address = new Address();
        address.setAddress("Siempre viva 123");
        address.setCity("Sprinfield");
        address.setCountry("US");
        address.setProvince("Sprinfield");

        u.setAddress(address);

        // userService.save(u);
        System.out.println("Elimina usuario:" + userService.removeUser(u));
        list = userService.getAll();
        for(User user : list){
            System.out.println(user);
        }
        
  
         u = new User();
        u.setFirstName("Marge");
        u.setLastName("Simpsons");
        u.setUsername("marge.simpsons");
        u.setPassword("marge");
        u.setPasswordHint("role?");
        u.setEmail("marge.simpsons@gmail.com");
        u.setPhoneNumber("555-555-5555");
        u.setWebsite("N/A");
        u.setEnabled(true);
        u.setAccountExpired(false);
        u.setAccountLocked(false);
        u.setCredentialsExpired(false);

         r = new Role();
        r.setName("admin");
        r.setDescription("All privileges");

        u.addRole(r);

        r = new Role();
        r.setName("operator");
        r.setDescription("Some privileges");

        u.addRole(r);

         address = new Address();
        address.setAddress("Siempre viva 123");
        address.setCity("Sprinfield");
        address.setCountry("US");
        address.setProvince("Sprinfield");

        u.setAddress(address);
        userService.removeUser(u);
//userService.save(u);

        list = userService.getAll();


        for(User user : list){
            System.out.println(user);
        }
*/
    }

   

}


